using UnityEngine;

public class ADrewards : MonoBehaviour
{
	public UIEventListener claimbtn;

	public Animator animator;
	//public Animation scaleanima;

	private GameObject objui;

	private bool isshow;

	private bool isDiamondFlag;

	public UISprite flagsp;

	public UILabel getnumlabel;

	private void Start()
	{
		claimbtn.onClick = OnClickclaimBtn;
	}

	public void enable()
	{
		isDiamondFlag = MenuPlayerprefs.IsDiamondADReward;
		if (isDiamondFlag)
		{
			flagsp.spriteName = "GY_zuanShi_03";
			getnumlabel.text = "1";
		}
		else
		{
			flagsp.spriteName = "CZ_jinBi_02";
			getnumlabel.text = "100";
		}
		isshow = true;
		if (objui == null)
		{
			objui = base.gameObject;
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: true);
		animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		Invoke("playanima", Time.deltaTime * 2f);
	}

	public void playanima()
	{
		/* scaleanima["PopWinAnimation"].time = 0f;
		scaleanima["PopWinAnimation"].speed = 1f;
		scaleanima.Play(); */
		animator.SetTrigger("popWin1");
	}

	public void OnClickclaimBtn(GameObject btn)
	{
		if (isshow)
		{
			isshow = false;
			save_info();
			MonoInstance<AudioController>.instance.play(AudioType.UI_getdiamond, 0f);
			/* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
			animator.SetTrigger("popWin2");
			Invoke("disable", animator.runtimeAnimatorController.animationClips[0].length);
		}
	}

	public void save_info()
	{
		if (isDiamondFlag)
		{
			MenuPlayerprefs.instance.AddDiamod(1);
		}
		else
		{
			MenuPlayerprefs.instance.AddMoney(100);
		}
	}

	public void disable()
	{
		animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		MenuBackController.instance.BackMenuUIstate();
		NGUITools.SetActive(objui, state: false);
	}
}
